-# locals: instance, id_prefix, seen_ids, is_root
-#instance = risky_attribute
-model_underscore = instance.class.name.underscore

-is_root = false if local_assigns[:is_root].nil?

-seen_ids = [] if local_assigns[:seen_ids].nil?
-id_prefix = "instance-#{instance.class.name.underscore}-#{instance.id}" if local_assigns[:id_prefix].nil?

-seen_this = seen_ids.include?(instance.id)

-expand_this = false #(!seen_this && sub_objects.count > 0)

-summary_toggle_target = "#{id_prefix}-summary"
-objects_toggle_target = "#{id_prefix}-objects"

-main_toggle_target = expand_this ? objects_toggle_target : summary_toggle_target

%li{ :class => instance.class.name.downcase, :'data-object-id' => instance.id}
  .item-main
    .openclose{ :class => 'lastchild' }
    .item-title
      .row-fluid
        =render :partial => 'object_leaf', :locals => { :instance => instance, :notes_attr => "" }
      .item-actions
        %a.btn.btn-mini.halfopacity{ "rel" => "tooltip", "data-placement" => "left", "title" => "Edit this object", 'data-modal-class' => 'modal-wide', 'data-form-target' => 'refresh', "data-toggle" => "modal-ajax-form", :href => url_for(:id => instance.id, :action => :edit, :controller => model_underscore.pluralize, :only_path => true) }
          %i.grcicon-edit
        -if !is_root
          %a.btn.btn-mini.halfopacity{ "rel" => "tooltip", "data-placement" => "left", "title" => "Go to this object's page", :href => url_for(:id => instance.id, :action => :show, :controller => model_underscore.pluralize, :only_path => true) }
            %i.grcicon-goto
